﻿namespace WMS6.Web.Outbound
{
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class LoadingQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlCarrierIDOper;
        protected DropDownList ddlCreatedByOper;
        protected DropDownList ddlCreatedDateOper;
        protected DropDownList ddlDepartureTimeOper;
        protected DropDownList ddlDoorOper;
        protected DropDownList ddlExternalIDOper;
        protected DropDownList ddlLoadIDOper;
        protected DropDownList ddlRouteOper;
        protected DropDownList ddlStatus;
        protected DropDownList ddlStatusOper;
        protected DropDownList ddlVehicleNumberOper;
        protected HtmlForm F7055;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlHead Head1;
        protected HtmlImage img1;
        protected HtmlImage img2;
        protected HtmlImage img3;
        protected HtmlImage img4;
        protected HtmlImage imgCarrierID;
        protected Label lblCarrierID;
        protected Label lblCreatedBy;
        protected Label lblCreatedDate;
        protected Label lblDepartureTime;
        protected Label lblDoor;
        protected Label lblExternalID;
        protected Label lblLoadID;
        protected Label lblQuery;
        protected Label lblRoute;
        protected Label lblStatus;
        protected Label lblVehicleNumber;
        protected HtmlLink mycss;
        protected TextBox txtCarrierID;
        protected TextBox txtCreatedBy;
        protected TextBox txtCreatedDate;
        protected TextBox txtCreatedDate2;
        protected TextBox txtDepartureTime;
        protected TextBox txtDepartureTime2;
        protected TextBox txtDoor;
        protected TextBox txtExternalID;
        protected TextBox txtLoadID;
        protected TextBox txtRoute;
        protected TextBox txtVehicleNumber;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("LoadingList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("LoadingList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void InitDropDownLists()
        {
            base.BindData2DDLBySysCode(this.ddlStatus, "LoadStatus");
            this.ddlStatus.Items.Insert(0, new ListItem("-----", ""));
            base.InitQueryDDL(this.ddlLoadIDOper, 0);
            base.InitQueryDDL(this.ddlStatusOper, 0);
            base.InitQueryDDL(this.ddlExternalIDOper, 0);
            base.InitQueryDDL(this.ddlCarrierIDOper, 0);
            base.InitQueryDDL(this.ddlCreatedByOper, 0);
            base.InitQueryDDL(this.ddlDoorOper, 0);
            base.InitQueryDDL(this.ddlRouteOper, 0);
            base.InitQueryDDL(this.ddlVehicleNumberOper, 0);
            base.InitQueryDDL(this.ddlDepartureTimeOper, 1);
            base.InitQueryDDL(this.ddlCreatedDateOper, 1);
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
            {
                this.btnNew.Visible = false;
                this.btnExport.Visible = false;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
                this.InitDropDownLists();
            }
        }

        public string CarrierID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCarrierID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCarrierID.Text.Trim(), this.ddlCarrierIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string CreatedBy
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCreatedBy.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCreatedBy.Text.Trim(), this.ddlCreatedByOper.SelectedValue);
                }
                return "";
            }
        }

        public string CreatedDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCreatedDate.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCreatedDate.Text.Trim(), this.ddlCreatedDateOper.SelectedValue, this.txtCreatedDate2.Text.Trim(), "CreatedDate");
                }
                return "";
            }
        }

        public string DepartureTime
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDepartureTime.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDepartureTime.Text.Trim(), this.ddlDepartureTimeOper.SelectedValue, this.txtDepartureTime2.Text.Trim(), "DepartureTime");
                }
                return "";
            }
        }

        public string Door
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtDoor.Text.Trim()))
                {
                    return base.GetParamsString(this.txtDoor.Text.Trim(), this.ddlDoorOper.SelectedValue);
                }
                return "";
            }
        }

        public string ExternalID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtExternalID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtExternalID.Text.Trim(), this.ddlExternalIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string LoadID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtLoadID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtLoadID.Text.Trim(), this.ddlLoadIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string Route
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtRoute.Text.Trim()))
                {
                    return base.GetParamsString(this.txtRoute.Text.Trim(), this.ddlRouteOper.SelectedValue);
                }
                return "";
            }
        }

        public string Status
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlStatus.SelectedValue))
                {
                    return base.GetParamsString(this.ddlStatus.SelectedValue, this.ddlStatusOper.SelectedValue);
                }
                return "";
            }
        }

        public string VehicleNumber
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtVehicleNumber.Text.Trim()))
                {
                    return base.GetParamsString(this.txtVehicleNumber.Text.Trim(), this.ddlVehicleNumberOper.SelectedValue);
                }
                return "";
            }
        }
    }
}

